package com.github.avatar.controller;

import com.github.avatar.model.ReactiveLog;
import com.github.avatar.util.DateStyle;
import com.github.avatar.biz.ReactiveLogBiz;
import com.github.avatar.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Stephen Liu
 * @since 2017/3/25
 */
@RestController
@RequestMapping("/reactive")
public class ReactiveLogController {

    @Autowired
    private ReactiveLogBiz reactiveLogBiz;

    @GetMapping("/{bizName}")
    public List<ReactiveLog> getReactive(@PathVariable String bizName) {

        String endTime = DateUtils.time(DateStyle.YYYY_MM_DD_HH_MM);

        //当前时间前10分钟
        String startTime = DateUtils.beforeTime(DateStyle.YYYY_MM_DD_HH_MM, 10);

        return reactiveLogBiz.findList(bizName, startTime, endTime);
    }
}
